package mil.af.amc.adpetracker.dao.hibernate;

import mil.af.amc.adpetracker.dao.DraDao;
import mil.af.amc.adpetracker.model.DRA;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Service;

/**
 * Hibernate implementation of DRA DAO
 *
 * @author TSgt Jason Ferguson
 */
@Service("draDao")
public class HibernateDraDao extends HibernateGenericDao<DRA> implements DraDao {

    public HibernateDraDao() {
        super(DRA.class);
    }

    public DRA getDraByName(final String draName) {

        DetachedCriteria crit = DetachedCriteria.forClass(DRA.class);
        crit.add(Restrictions.eq("draName", draName));
        return (DRA) getHibernateTemplate().findByCriteria(crit).get(0);

    }

}
